package com.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;
import java.util.stream.IntStream;

/**
 * @author Yadasu
 * @date 2021/1/12 14:10
 */
@Data
@Entity
@Table(name = "sys_installation_package_manage")
@JsonInclude(JsonInclude.Include.NON_NULL)
public class SysVersionManage implements Serializable{

    private static final long serialVersionUID = -3802895130262770398L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "deploy_id")
    @ApiModelProperty(value = "版本管理表id")
    private Integer deployId;
    @Column(name = "installation_package_name")
    @ApiModelProperty(value = "版本包名")
    private String packageName;

    @Column(name = "installation_package_version")
    @ApiModelProperty(value = "部署版本号")
    private String packageVersion;

    @Column(name = "current_version")
    @ApiModelProperty(value = "当前版本号")
    private String currentVersion;

    @Column(name = "create_by")
    @ApiModelProperty(value = "版本包创建人")
    private String createBy;

    @ApiModelProperty(value = "本地存储路径")
    private String url;

    @Column(name = "update_by")
    @ApiModelProperty(value = "版本包更新人")
    private String updateBy;

    @Column(name = "project_file_name")
    @ApiModelProperty(value = "项目文件名")
    private String fileName;


    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
    @Column(name = "create_time")
    @ApiModelProperty(value = "版本包创建时间")
    private Date createdTime;

    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
    @Column(name = "update_time")
    @ApiModelProperty(value = "版本包更新时间")
    private Date updatedTime;
    @ApiModelProperty(value = "当前版本状态情况")
    private Integer status;

    @ApiModelProperty(value = "项目部署状态状态信息")
    @Column(name = "remote_development")
    private Integer remoteDevelopment;


    @OneToOne(fetch = FetchType.EAGER)
    @JoinTable(name="sys_server_package_version",//中间表的名称

            joinColumns={@JoinColumn(name="deploy_id",referencedColumnName="deploy_id")},

            inverseJoinColumns={@JoinColumn(name="server_id",referencedColumnName="server_id")}

    )
    private SysServer sysServer;


    @OneToOne (fetch = FetchType.EAGER)
    @JoinTable(name="sys_history_package_version",//中间表的名称
            //中间表user_role字段关联sysuser表的主键字段id
            joinColumns={@JoinColumn(name="deploy_id",referencedColumnName="deploy_id")},
            inverseJoinColumns={@JoinColumn(name="history_id",referencedColumnName="history_id")}
            //中间表user_role的字段关联sysrole表的主键id
    )
    private SysDeployHistory sysDeployHistory;
}
